#include <sys/syscall.h>
#include <sys/shm.h>
#include <stdint.h>

void sys_sleep(uint32_t time)
{
    invoke_syscall(SYSCALL_SLEEP, time, IGNORE, IGNORE, IGNORE);
}

void sys_write(char *buff)
{
    invoke_syscall(SYSCALL_WRITE, (uintptr_t)buff, IGNORE, IGNORE, IGNORE);
}

void sys_reflush()
{
    invoke_syscall(SYSCALL_REFLUSH, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_move_cursor(int x, int y)
{
    invoke_syscall(SYSCALL_CURSOR, x, y, IGNORE, IGNORE);
}
/*
void sys_futex_wait(volatile uint64_t *val_addr, uint64_t val)
{
    invoke_syscall(SYSCALL_FUTEX_WAIT, (uintptr_t)val_addr, val, IGNORE);
}

void sys_futex_wakeup(volatile uint64_t *val_addr, int num_wakeup)
{
    invoke_syscall(SYSCALL_FUTEX_WAKEUP, (uintptr_t)val_addr, num_wakeup, IGNORE);
}
*/
int binsemget(int key)
{
    return invoke_syscall(SYSCALL_BINSEMGET, key, IGNORE, IGNORE, IGNORE);
}

int binsemop(int binsem_id, int op)
{
    return invoke_syscall(SYSCALL_BINSEMOP,binsem_id, op, IGNORE, IGNORE);
}

int condget(int key)
{
    return invoke_syscall(SYSCALL_CONDGET, key, IGNORE, IGNORE, IGNORE);
}

int condop(int cond_id, int op)
{
    return invoke_syscall(SYSCALL_CONDOP, cond_id, op, IGNORE, IGNORE);
}

int barrierget(int key, unsigned count)
{
    return invoke_syscall(SYSCALL_BARRIERGET, key, count, IGNORE, IGNORE);
}

int barrierop(int barrier_id)
{
    return invoke_syscall(SYSCALL_BARRIEROP, barrier_id, IGNORE, IGNORE, IGNORE);
}

long sys_get_timebase()
{
    return invoke_syscall(SYSCALL_GET_TIMEBASE, IGNORE, IGNORE, IGNORE, IGNORE);
}

long sys_get_tick()
{
    return invoke_syscall(SYSCALL_GET_TICK, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_process_show()
{
    invoke_syscall(SYSCALL_PS, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_screen_clear(int line1, int line2)
{
    invoke_syscall(SYSCALL_SCREEN_CLEAR, line1, line2, IGNORE, IGNORE);
}

int sys_get_char()
{
    int ch = -1;
    while (ch == -1) {
        ch = invoke_syscall(SYSCALL_GETCHAR, IGNORE, IGNORE, IGNORE, IGNORE);
    }
    return ch;
}

void sys_putchar(char ch)
{
    invoke_syscall(SYSCALL_PUTCHAR, ch, IGNORE, IGNORE, IGNORE);
}

int32_t sys_spawn(void *info, void* arg, int mode)
{
    return invoke_syscall(SYSCALL_SPAWN, (long)info, arg, mode, IGNORE);
}

int sys_kill(int32_t pid)
{
    return invoke_syscall(SYSCALL_KILL, pid, IGNORE, IGNORE, IGNORE);
}

void sys_exit(void)
{
    invoke_syscall(SYSCALL_EXIT, IGNORE, IGNORE, IGNORE, IGNORE);
}

int sys_waitpid(int32_t pid)
{
    return invoke_syscall(SYSCALL_WAITPID, pid, IGNORE, IGNORE, IGNORE);
}

int32_t sys_getpid()
{
    return invoke_syscall(SYSCALL_GETPID, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_send_mailbox(int mailbox, void *msg, int msg_length)
{
    invoke_syscall(SYSCALL_MAILBOX_SEND, mailbox, msg, msg_length, IGNORE);
}

void sys_recv_mailbox(int mailbox, void *msg, int msg_length)
{
    invoke_syscall(SYSCALL_MAILBOX_RECV, mailbox, msg, msg_length, IGNORE);
}

int32_t sys_exec(const char *file_name, int argc, char* argv[], int mode)
{
    return invoke_syscall(SYSCALL_EXEC, (uintptr_t)file_name, argc, (uintptr_t)argv, mode);
}

void sys_show_exec()
{
    invoke_syscall(SYSCALL_SHOW_EXEC, IGNORE, IGNORE, IGNORE, IGNORE);
}

void* shmpageget(int key)
{
    return invoke_syscall(SYSCALL_SHMPGET, key, IGNORE, IGNORE, IGNORE);
}

void shmpagedt(void *addr)
{
    invoke_syscall(SYSCALL_SHMPDT, (uintptr_t)addr, IGNORE, IGNORE, IGNORE);
}

int sys_mkfs()
{
    return invoke_syscall(SYSCALL_MKFS, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_statfs()
{
    invoke_syscall(SYSCALL_STATFS, IGNORE, IGNORE, IGNORE, IGNORE);
}

int sys_mkdir(char *name)
{
    return invoke_syscall(SYSCALL_MKDIR, name, IGNORE, IGNORE, IGNORE);
}

void sys_show_files()
{
    invoke_syscall(SYSCALL_SHOW_FILES, IGNORE, IGNORE, IGNORE, IGNORE);
}

void sys_rmdir(char *name)
{
    invoke_syscall(SYSCALL_RMDIR, name, IGNORE, IGNORE, IGNORE);
}

int sys_cd(char *name)
{
    return invoke_syscall(SYSCALL_CD, name, IGNORE, IGNORE, IGNORE);
}

int sys_touch(char *name, int block_size)
{
    return invoke_syscall(SYSCALL_TOUCH, name, block_size, IGNORE, IGNORE);
}

void sys_cat(char *name)
{
    invoke_syscall(SYSCALL_CAT, name, IGNORE, IGNORE, IGNORE);
}

int sys_fopen(char *name, int access)
{
    return invoke_syscall(SYSCALL_FOPEN, name, access, IGNORE, IGNORE);
}

int sys_fread(int fd, char *buff, int size)
{
    return invoke_syscall(SYSCALL_FREAD, fd, buff, size, IGNORE);
}

int sys_fwrite(int fd, char *buff, int size)
{
    return invoke_syscall(SYSCALL_FWRITE, fd, buff, size, IGNORE);
}

void sys_fclose(int fd)
{
    invoke_syscall(SYSCALL_FCLOSE, fd, IGNORE, IGNORE, IGNORE);
}

void sys_ln(char *src, char *dest)
{
    invoke_syscall(SYSCALL_LN, src, dest, IGNORE, IGNORE);
}

void sys_ln_s(char *src, char *dest)
{
    invoke_syscall(SYSCALL_LNS, src, dest, IGNORE, IGNORE);
}

void sys_movepos(int fd, int type, int pos)
{
    invoke_syscall(SYSCALL_MOVEPOS, fd, type, pos, IGNORE);
}